package com.wisely.ch8_5.web;

import com.wisely.ch8_5.domain.Person;
import com.wisely.ch8_5.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CacheController {
    @Autowired
    private IPersonService personService;

    @RequestMapping("/put")
    public Person put(Person person) {
        return personService.save(person);
    }

    @RequestMapping("/able")
    public Person cacheable(Person person) {
        return personService.findOne(person);
    }

    @RequestMapping("/evit")
    public String evit(Long id) {
        personService.remove(id);

        return "OK";
    }
}
